/*
 *  renderer.h
 *  
 *  Created by James Dykstra
 *	Team 5
 *
 *  Copyright 2010 Michigan Technological University. All rights reserved.
 */

#ifndef RENDERER_H
#define RENDERER_H

//Defined constants specifying the resolution to use
#define RES_WIDTH 1024
#define RES_HEIGHT 768
#define SCREEN_BPP 32

#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_opengl.h"
#include <CEGUI.h>
#include <RendererModules/OpenGL/CEGUIOpenGLRenderer.h>
#include <string>
//Just used for outputting to a log file, temporary
#include <fstream>

class Renderer
{
public:
	Renderer();
	~Renderer();

	void update();

	//Used to load an image from file to an SDL_Surface, see .cpp for details
	SDL_Surface *loadImage(std::string filename);

	//Creates an OpenGL texture from an SDL_Surface*
	GLuint       createTexture(SDL_Surface *);

	//Draws the specified surface at the given coordinates/pos with the possibly specified clip, see .cpp for details.
	void         drawSurface(SDL_Rect *pos, GLfloat angle, GLuint texture);

	//For per-pixel collision detection
	Uint32       getPixelAt(SDL_Surface*, int, int);
    bool                    ingame;
    bool                    exit;
    bool                    isserver;
	
	//used by the map to draw itself
	int			 getScreenWidth();
	int			 getScreenHeight();

	void		 drawBox(float,float,float,float,float,float,float,float);
    void         setHealth(int currenthealth, int maxhealth );
    void         setIP(std::string ipaddressstring);
    void         setPort(std::string portstring);
    CEGUI::String getPort();
    CEGUI::String getIP();

private:
	SDL_Surface				*screen;

	bool					isPow2(int n){ return ( (n > 0) && ((n & (n - 1)) == 0) ); };

    //method for control of the gui
    void                    guiDraw();
    bool                    handleButton(const CEGUI::EventArgs& e);
    bool                    handleRadio(const CEGUI::EventArgs& e);
    CEGUI::Window *         myRoot;
    CEGUI::Window *         myHUD;
    CEGUI::Window *         myOptions;
    CEGUI::Window *         myLoadout;

    
};

#endif
